#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 5e5 + 5;

int n, m;
int a[N], b[N], num;
int sum[N << 2];
void pushup(int p) { sum[p] = sum[p << 1] + sum[p << 1 | 1]; }
void update(int x, int d, int p, int l, int r) {
  if (l == r) {
    sum[p] += d;
    return;
  }
  int mid = (l + r) >> 1;
  if (x <= mid)
    update(x, d, p << 1, l, mid);
  else
    update(x, d, p << 1 | 1, mid + 1, r);
  pushup(p);
}
int query(int L, int R, int p, int l, int r) {
  if (L > R) return 0;
  if (L <= l && R >= r) return sum[p];
  int mid = (l + r) >> 1;
  int res = 0;
  if (L <= mid) res += query(L, R, p << 1, l, mid);
  if (R > mid) res += query(L, R, p << 1 | 1, mid + 1, r);
  return res;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  rep(i, 1, n) cin >> a[i];
  rep(i, 1, n) b[i] = a[i];
  sort(b + 1, b + n + 1);
  num = unique(b + 1, b + n + 1) - b - 1;
  rep(i, 1, n) a[i] = lower_bound(b + 1, b + num + 1, a[i]) - b;
  ll ans = 0;
  rep(i, 1, n) {
    ans += query(a[i] + 1, num, 1, 1, n);
    update(a[i], 1, 1, 1, n);
  }
  cout << ans;
  return 0;
}